package cn.maihe.elg.operation.repository.entity;

import cn.maihe.elg.operation.repository.entity.CustomerAttachmentVo;
import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_customer_attachment")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.CustomerAttachmentMapper")
public class CustomerAttachmentDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 客户主键id
     */
    @TableField(value = "bidder_id")
    private Long bidderId;

    /**
     * 附件类型
     */
    @TableField(value = "attach_type")
    private String attachType;

    /**
     * 附件路径
     */
    @TableField(value = "attach_path")
    private String attachPath;

    /**
     * 文件名
     */
    @TableField(value = "attach_file_name")
    private String attachFileName;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 附件大写md5值
     */
    @TableField(value = "file_md5")
    private String fileMd5;

    /**
     * 附件原下载地址
     */
    @TableField(value = "file_url")
    private String fileUrl;

    public CustomerAttachmentVo buildVo() {
        return new CustomerAttachmentVo(id, bidderId, attachType, attachPath, attachFileName, gmtCreate, gmtModified, userCreate, userModified,fileMd5,fileUrl);
    }

    public static CustomerAttachmentDO of(CustomerAttachmentVo vo) {
        return new CustomerAttachmentDO(vo.getId(), vo.getBidderId(), vo.getAttachType(), vo.getAttachPath(), vo.getAttachFileName(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(),vo.getFileMd5(),vo.getFileUrl());
    }
}
